﻿Imports Training.Common

Partial Public Class DeleteQuizQuestion
    Inherits System.Web.UI.Page
    Dim qid As Integer ' quizid
    Dim qsid As Integer ' questionid
    Dim qnm As String ' quizname

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' check for querystring data
        If IsNothing(Request.QueryString("qid")) Or IsNothing(Request.QueryString("qsid")) Or IsNothing(Request.QueryString("qnm")) Then
            Response.Redirect("QuizControl.aspx")
        Else
            qid = Request.QueryString("qid")
            qsid = Request.QueryString("qsid")
            qnm = Request.QueryString("qnm")
            lblQuestion.Text = GetQuestionTextByQuestionID(qsid)
            lblQuiz.Text = qnm
        End If
    End Sub

    ''' <summary>
    ''' Cancel button click event
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Response.Redirect("QuizControl.aspx")
    End Sub

    ''' <summary>
    ''' Delete button click event
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        If DeleteXRefQuizQuest(qid, qsid) = 0 Then
            Response.Redirect("QuizControl.aspx")
        Else
            lblMsg.Text = "Error deleting Quiz Question. Please try again."
        End If
    End Sub
End Class